package com.wc.codeforces.前缀和与差分.前缀和.Kousuke_Assignment;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

/**
 * @Author congge
 * @Date 2024/10/24 23:25
 * @description https://codeforces.com/contest/2033/problem/D
 */
public class Main {
    /**
     * DP + 2分 + 记录位置 + 前缀和
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 100010;
    static int[] a = new int[N], f = new int[N];
    static long[] s = new long[N];
    static Map<Long, ArrayList<Integer>> map = new HashMap<>();
    static int n;

    public static void main(String[] args) {
        int T = sc.nextInt();
        while (T-- > 0) {
            map.clear();
            n = sc.nextInt();
            Arrays.fill(f, 1, n + 1, 0);
            for (int i = 1; i <= n; i++) a[i] = sc.nextInt();
            for (int i = 1; i <= n; i++) s[i] = s[i - 1] + a[i];
            map.put(0L, new ArrayList<>());
            map.get(0L).add(0);
            for (int i = 1; i <= n; i++) {
                ArrayList<Integer> array = map.getOrDefault(s[i], new ArrayList<>());
                array.add(i);
                map.put(s[i], array);
            }
            for (int i = 1; i <= n; i++) {
                if (map.containsKey(s[i])) {
                    ArrayList<Integer> array = map.get(s[i]);
                    if (array.size() >= 2) {
                        int l = 0, r = array.size();
                        while (l < r) {
                            int mid = l + r + 1 >> 1;
                            if (array.get(mid) < i) l = mid;
                            else r = mid - 1;
                        }
                        if (array.get(r) < i) f[i] = f[array.get(r)] + 1;
                    }
                }
                f[i] = Math.max(f[i], f[i - 1]);
            }
            out.println(f[n]);
        }
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}